<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>归口部门限项</title>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
</head>

<body>
	<input type="hidden" id="childDiv" class="thickbox" />
	<form method="post" id="mainForm">
			<input type="hidden" id="prpCodes" name="prpCodes" value="" />
			<input type="hidden" id="type" name="type" value="" />
    </form>
	<div class="soBox">
		<div class="detail ico_search">
			<table>
				<tr>
					<td ><strong>检索条件：</strong>
					</td>
					<td>
                        <cpt:search key="orgRecommendLimit_search"  repeatColumn="3" displayCount="6" leftStyle="width:80px"></cpt:search>
					</td>
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
  <iframe id="ifile" style="display:none"></iframe>
	<script type="text/javascript">
	var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
	var prcWin = new progressWin("${res}"); //初始化遮罩层
	
	/**
	* 表格初始化
	*/
    function buildGrid() {
		
        var columnAttrList = new Array();
        var columnAttr = new ColumnAttr("业务年度", "stat_year","stat_year", 2, "center", true);
        columnAttrList.push(columnAttr);
        
        columnAttr = new ColumnAttr("计划类别", "plan_name","NLSSORT(plan_name, 'NLS_SORT = SCHINESE_PINYIN_M')", 3, "center", true);
        columnAttrList.push(columnAttr);
      
        columnAttr = new ColumnAttr("项目类别", "grant_name","NLSSORT(grant_name, 'NLS_SORT = SCHINESE_PINYIN_M')", 3, "center", true);
        columnAttrList.push(columnAttr);
      
        columnAttr = new ColumnAttr("归口管理部门", "recommend_org","NLSSORT(recommend_org, 'NLS_SORT = SCHINESE_PINYIN_M')", 3, "center", true);
        columnAttrList.push(columnAttr);
      
        columnAttr = new ColumnAttr("管理处室", "office_name","NLSSORT(office_name, 'NLS_SORT = SCHINESE_PINYIN_M')", 3, "center", true);
        columnAttrList.push(columnAttr);
      
        columnAttr = new ColumnAttr("申报批次", "batch","NLSSORT(batch, 'NLS_SORT = SCHINESE_PINYIN_M')", 2, "center", true);
        columnAttrList.push(columnAttr);
      
        columnAttr = new ColumnAttr("设置上限", "limit_num","limit_num", 2, "center", true);
        columnAttrList.push(columnAttr);
        
        columnAttr = new ColumnAttr("操作", "", "", 3,"center", false);
        columnAttrList.push(columnAttr);
        
        irisGrid.setColumnAttrs(columnAttrList);

		irisGrid.setToolsBar([ {
				id : 'add',
				name : '新增 ',
				trigger : add
			} ]);
		
        irisGrid.setUrl("${ctx}/prpapprove/listOrgRecommendLimit"); //查询url
        irisGrid.setCaption("归口限项");
        irisGrid.setDefaultSortName("NLSSORT(stat_year,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(plan_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(grant_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(recommend_org,'NLS_SORT = SCHINESE_PINYIN_M')");//默认排序字段
        irisGrid.setDefaultSortorder("asc");
        irisGrid.setWidth(978); //整个表格宽度
		irisGrid.setLazyLoad(true);
        irisGrid.setCheckAble(false); //表格左边是否要复选框
        irisGrid.setShowRowIndex(true); //是否显示行号
        irisGrid.setCanExportExcel(true);
        irisGrid.setQueryBox('searchBt', 'orgRecommendLimit_search'); //查询条件 按钮名，查询条件function_key
     
        /*irisGrid.setLoadComplete(function() {
            irisGrid.attendQuery = true;
            var searchString = irisGrid.preDealOnQuery()['searchString'];
            $("#searchString").val(searchString);
            $("#sortItem").val( irisGrid.getGridDom().jqGrid("getGridParam", 'sortname'));
            $("#sortType").val(irisGrid.getGridDom().jqGrid("getGridParam", 'sortorder'));
           
        }); */
        irisGrid.build();
        
		}
	
	function edit(grantCode,orgCode,statYear,batch) {
      tb_show("编辑限项",ctx+'/prpapprove/editOrgRecommendLimit?type=edit&grantCode=' + grantCode+'&orgCode='+ orgCode+'&statYear='+ statYear+'&batch='+ batch+ '&TB_iframe=true&height=220&width=700');
      $(parent.document).find("#TB_ajaxWindowTitle").text("编辑限项");
	}
	function del(grantCode,orgCode,statYear,batch) {debugger;
        if(window.confirm("确认删除？")) {
        	 $.ajax({
                 type: "POST",
                 async:false,
                 url: "${ctx}/prpapprove/deleteOrgRecommendLimit",
                 data: {"grantCode":grantCode,
                	 "orgCode":orgCode,
                	 "statYear":statYear,
                	 "batch":batch
                 },
                 beforeSend:function(XMLHttpRequest) {
                	 prcWin.openWin();//打开遮罩层
                     $("#approve").attr("disabled",true);
                 },
                 success: function(msg){
                     prcWin.closeWin();
                     if(msg == "success") {
                         scmSuccess("删除成功!");
                         irisGrid.getGridDom().jqGrid("refresh",0); //0是本页1是首页
                         $("input[type='button'][id!='back']").attr("disabled",false);
                         return;
                     } else if(msg == "fail"){
                         scmError("操作失败,请联系系统管理员");
                         irisGrid.getGridDom().jqGrid("refresh",0); //0是本页1是首页
                         $("input[type='button'][id!='back']").attr("disabled",false);
                         return;
                     }
                 }, // 表单成功提交后的回调函数
                 error : function() {
                     scmError("操作失败,请联系系统管理员");
                     $("input[type='button'][id!='back']").attr("disabled",false);
                     prcWin.closeWin();
                     irisGrid.getGridDom().jqGrid("refresh",0); //0是本页1是首页
                 }
              });
        }
    }
	function add() {
	    tb_show("新增限项",ctx+'/prpapprove/addOrgRecommendLimit?type=add&TB_iframe=true&height=220&width=700');
	    $(parent.document).find("#TB_ajaxWindowTitle").text("新增限项");
	}
	
	/**
	* 页面加载完毕初始化函数
	*/
	$(function(){
        queryflex();
		buildGrid();
        $("div[class*='ui-jqgrid-bdiv']").css("overflow","hidden");
        $("#TopBarMnt").css("width","971px");
        $("#cb_dataGrid").click(function(){
            var checked=$(this).attr("checked");
            if(checked=="checked"){
                $("#dataGrid").find("td input[type='checkbox']").attr("checked","checked");
                $("#dataGrid").find("tr[class*='jqgrow']").each(function(){
                    if($(this).find("td input[type='checkbox']").length<=0){
                        $(this).removeClass("ui-state-highlight");
                    }
                });
                
            }else{
                $("#dataGrid").find("td input[type='checkbox']").attr("checked",false);
            }
        });
	});
	</script>
</body>
</html>